<?php

class article extends Control{
	
	/* 获取文章id,typeid,flag,click,title,writer,litpic,pubdate,description
	typeid    栏目id
	page      第几页
	per_page  每页多少条
	orderby   排序字段
	asc       升序降序 asc,desc
	*/
    public function ac_getarts(){
		$typeid = Request('typeid','all');
		$page = Request('page','1');
		$per_page = Request('per_page','10');
		$orderby = Request('orderby','id');
		$asc = Request('asc','asc');
		$res = $this->Model('archives')->article($typeid,$page,$per_page,$orderby,$asc);
		echo json_encode($res);
	}
	
	//根据ID获取文章
	public function ac_getartbyid(){
		$aid = Request('id');
		$res = $this->Model('archives')->getartbyid($aid);
		echo json_encode($res);
	}

	//列出文章
	public function ac_artlist(){
		$typeid = Request('typeid','all');
		$page = Request('page','1');
		$per_page = Request('per_page','10');
		$orderby = Request('orderby','id');
		$asc = Request('asc','asc');
		$res = $this->Model('archives')->article($typeid,$page,$per_page,$orderby,$asc);
		
		$tp = new DedeTemplate;
		$tp->SetVar("host",$_SERVER['HTTP_HOST']);
		$tp->SetArray("art",$res);
		$tp->LoadTemplate(DEDEROOT."/api/templates/test.htm");
		$tp->Display();
	}

}